#!/usr/bin/python

import cv2
import sys

if len(sys.argv) < 2:
    # with no arguments, use this default file
    filename = "/home/tutorial/Tutorial/Data/photo.jpg"
elif len(sys.argv) == 2:
    filename = sys.argv[1]
else:
    sys.exit("Expecting a single image file argument")

image = cv2.imread(filename)
image_small = cv2.resize(image, (image.shape[1] / 4, image.shape[0] / 4))
image_gray = cv2.cvtColor(image_small, cv2.cv.CV_RGB2GRAY)
features = cv2.goodFeaturesToTrack(image_gray, 50, .01, 50)
features = features.reshape((-1, 2))
for x, y in features:
    cv2.circle(image_small, (x, y), 10, (0, 0, 255))
cv2.imshow('OpenCV Features Example', image_small)
cv2.waitKey()
cv2.destroyAllWindows()
